package com.yehui.jdk.reflect;

import java.lang.reflect.Field;

/**
 * @author 业徽
 * @date 2021/3/16
 */
public class ReflectFun {

    /**
     * 获取静态属性的值
     *
     * @param type
     * @param name
     * @return
     */
    public static Object getStaticField(Class<?> type, String name) throws NoSuchFieldException, IllegalAccessException {
        final Field declaredField = type.getDeclaredField(name);
        declaredField.setAccessible(true);
        return declaredField.get(null);
    }

}
